import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { ArcoResolver } from 'unplugin-vue-components/resolvers'


const indexReplace = () => {
  return {
      name: 'html-transform',
      transformIndexHtml(html) {
          return minify(html, {
              collapseWhitespace: true,
          })
      },
  }
}

function importSvelte(libraryName, dir = 'src') {
  return {
      libraryName,
      camel2DashComponentName: false,
      customName: name => `${libraryName}/${dir}/${name}.svelte`,
  }
}
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),
    Components({
      resolvers: [
        ArcoResolver()
      ]
    })
  ],
  // hmr:true,
  server:{
    proxy:{
      '/api': {
        target: 'http://localhost:5000',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '/api')
      },
    }
  },
  resolve: {
    alias: {
      '~': path.resolve(__dirname, 'src'),
    },
  },
})
